<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta name="keywords" content="" />
<meta name="description" content="" />
<title>个人信箱</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"content="width=device-width, initial-scale=1, maximum-scale=1">
<script src="../../../js/angular.js"></script>
<link rel="stylesheet" href="../../../layui/css/layui.css" media="all">
<script type="text/javascript" src="../../../layui/lay/modules/layer.js"></script>
<script src="../../../layui/jquery-3.2.1.min.js" charset="utf-8"></script>
<script src="../../../layui/layui.js" charset="utf-8"></script>
<style type="text/css">
#menu {
	height: 459px;
	float: right;
	top: 10px;
	width: 25%;
	float: left;
}

#page_container {
	border: 0px;
	margin: 10px;
	width: auto;
	margin: 0 auto;
	text-align: left;
}

#xx {
	height: 459px;
	float: left;
	top: 10px;
	width: 50%;
}

#js {
	height: 459px;
	float: left;
	top: 20px;
	width: 50%;
}

#yf {
	height: 459px;
	float: left;
	top: 20px;
	width: 50%;
}
</style>
</head>
<body id="page_container">
<br><br><br>
	<div ng-app="myApp" ng-controller="customersCtrl" align="center">
		<div id="menu" ng-mouseover="">
			<ul class="layui-nav layui-nav-tree layui-inline"
				style="text-align: left;width: 70%">
				<li class="layui-nav-item" ng-click="fsyj()"><a
					href="javascript:;">发送邮件</a></li>
				<li class="layui-nav-item" ng-click="jsyj()"><a
					href="javascript:;">接收邮件</a></li>
				<li class="layui-nav-item" ng-click="yfyj()"><a
					href="javascript:;">已发邮件</a></li>
			</ul>
		</div>
		<!-- 发送邮件 -->
		<div class="layui-tab-item layui-show" ng-hide="fsyjdiv"
			style="float:left;width:60%;">

			<div class="layui-form-item">
				<label class="layui-form-label">主题：</label>
				<div class="layui-input-block">
					<input name="title" ng-model="zhuti" lay-verify="title"
						autocomplete="off" placeholder="关于提取需要准备的相关质料都有什么"
						class="layui-input" type="text">
				</div>
			</div>
			<div class="layui-form-item layui-form-text">
				<label class="layui-form-label">正文：</label>
				<div class="layui-input-block">
					<textarea ng-model="zhengwen" style="height:200px"
						placeholder="关于提取需要准备的相关质料都有什么" class="layui-textarea"></textarea>
				</div>
			</div>
			<div class="layui-form-item">
				<div class="layui-input-block">
					<button class="layui-btn" lay-submit="" lay-filter="demo1"
						ng-click="tj()">提交</button>
					<button type="reset" class="layui-btn layui-btn-primary"
						ng-click="cz()">重置</button>
				</div>
			</div>
		</div>
		<!-- 接收邮件 -->
		<div ng-hide="jsyjdiv" style="float:left;width:70%;">
			<div style="float: left;width: 80%">
				<table class="layui-table">
					<tr align="center" style="background-color:#f1f1f1">
						<td>发件人</td>
						<td>发件时间</td>
						<td>主题</td>
						<td ng-hide="true" ng-model="id">id</td><!-- ng-show="false" -->
						<td ng-show="false">行数</td>
					</tr>
					<tr ng-repeat="x in names" align="center">
						<td ng-if="$odd" style="background-color:#f1f1f1">{{ x.FJR}}</td>
						<td ng-if="$even">{{ x.FJR}}</td>
						<td ng-if="$odd" style="background-color:#f1f1f1">{{ x.FSRQ}}</td>
						<td ng-if="$even">{{ x.FSRQ}}</td>
						<td ng-if="$odd" style="background-color:#f1f1f1">{{ x.ZT}}</td>
						<td ng-if="$even">{{ x.ZT }}</td>
						<td ng-if="$odd" style="background-color:#f1f1f1" ng-hide="true">{{ x.id}}</td>
						<td ng-if="$even" ng-hide="true">{{ x.id }}</td>
						<td ng-if="$odd" style="background-color:#f1f1f1" ng-click="ck($index)"><button type="button">查看</button></td>
						<td ng-if="$even"  ng-click="ck($index)"><button type="button">查看</button></td>
					</tr>
				</table>
				<div class="layui-btn-group">
					<button class="layui-btn layui-btn-primary layui-btn-sm"
						ng-click="Sy()">首页</button>
					<button class="layui-btn layui-btn-primary layui-btn-sm"
						ng-click="Previous()">上一页</button>
					<button ng-repeat="page in pageList"
						class="layui-btn layui-btn-primary layui-btn-sm "
						ng-click="selectPage(page)">{{page}}</button>
					<button class="layui-btn layui-btn-primary layui-btn-sm"
						ng-click="Next()">下一页</button>
					<button class="layui-btn layui-btn-primary layui-btn-sm"
						ng-click="Wy()">尾页</button>
					<button class="layui-btn layui-btn-primary layui-btn-sm ">{{selPage}}/{{pages}}</button>
				</div>
			</div>
		</div>
		<!-- 已发邮件 -->
		<div ng-hide="yfyjdiv" style="float:left;width:70%;">
			<div style="float: left;width: 80%">
				<table class="layui-table">
					<tr align="center" style="background-color:#f1f1f1">
					    <td ng-show="false">行数</td>
						<td>发件人</td>
						<td>发件时间</td>
						<td>主题</td>
						<td>操作</td>
						<td ng-show="false">id</td>
					</tr>
					<tr ng-repeat="x in names" align="center">
					<td ng-if="$odd" style="background-color:#f1f1f1" ng-show="false">{{$index}}</td>
						<td ng-if="$even" ng-show="false">{{$index}}</td>
						<td ng-if="$odd" style="background-color:#f1f1f1">{{ x.FJR}}</td>
						<td ng-if="$even">{{ x.FJR}}</td>
						<td ng-if="$odd" style="background-color:#f1f1f1">{{ x.FSRQ}}</td>
						<td ng-if="$even">{{ x.FSRQ}}</td>
						<td ng-if="$odd" style="background-color:#f1f1f1">{{ x.ZT}}</td>
						<td ng-if="$even">{{ x.ZT }}</td>
						<td ng-if="$odd" style="background-color:#f1f1f1" ng-show="false">{{ x.id}}</td>
						<td ng-if="$even" ng-show="false">{{ x.id }}</td>
						<td ng-if="$odd" style="background-color:#f1f1f1" ng-click="ck($index)"><button type="button">查看</button></td>
						<td ng-if="$even"  ng-click="ck($index)"><button type="button">查看</button></td>
					</tr>
				</table>
				<div class="layui-btn-group">
					<button class="layui-btn layui-btn-primary layui-btn-sm"
						ng-click="Sy()">首页</button>
					<button class="layui-btn layui-btn-primary layui-btn-sm"
						ng-click="Previous()">上一页</button>
					<button ng-repeat="page in pageList"
						class="layui-btn layui-btn-primary layui-btn-sm "
						ng-click="selectPage(page)">{{page}}</button>
					<button class="layui-btn layui-btn-primary layui-btn-sm"
						ng-click="Next()">下一页</button>
					<button class="layui-btn layui-btn-primary layui-btn-sm"
						ng-click="Wy()">尾页</button>
					<button class="layui-btn layui-btn-primary layui-btn-sm ">{{selPage}}/{{pages}}</button>
				</div>
			</div>
		</div>
		 <!-- 查看按钮DIV  -->
		<div ng-hide="ckdiv" style="float:left;width:70%;">
		   <div class="layui-form-item">
				<label class="layui-form-label">主题：</label>
				<div class="layui-input-block">
					<input name="title" ng-model="ckzhuti2" lay-verify="title"
						autocomplete="off" class="layui-input" type="text" readonly>
				</div>
			</div>
			<div class="layui-form-item layui-form-text">
				<label class="layui-form-label">正文：</label>
				<div class="layui-input-block">
					<textarea ng-model="ckzhengwen" style="height:200px" class="layui-textarea" readonly></textarea>
				</div>
			</div>
		</div>
	</div>



	<script>
		layui.use('element', function() {
			var $ = layui.jquery, element = layui.element;
		});
	</script>
	<script type="text/javascript">
	
	function getPath() {  
	     
	        return 'http://'+location.host;
	}
		
		
	</script>
	<script type="text/javascript" src="../../../layui/lay/modules/layer.js"></script>
	<script type="text/javascript" src="../../../layui/layer.ext.js"></script>
	<script>
		var app = angular.module('myApp', []);
		app.controller('customersCtrl', function($scope, $http) {
			$scope.jsyjdiv = true;
			$scope.yfyjdiv = true;
			$scope.ckdiv=true;
			/** 接受邮件JS */
			$scope.jsyj = function() {
				$scope.fsyjdiv = true;
				$scope.jsyjdiv = false;
				$scope.yfyjdiv = true;
				$scope.ckdiv=true;
				$scope.params = {
					id : $scope.id,
				};
				$http({
					url : getPath() + "/wsyyt/grXinXController/test1",
					contentType : "text/html;charset=utf-8",
					method : 'post',
					params : $scope.params,
				}).then(function(res) {
					$scope.data = res.data.data;
				   	 if(res.data.code==1){
				   	 	layer.msg('提示：'+res.data.CW,{icon: 5});
				   	 }
                 $scope.pageSize = 8;//设置显示行数
      $scope.pages = Math.ceil($scope.data.length / $scope.pageSize); //分页数
      $scope.newPages = $scope.pages > 5 ? 5 : $scope.pages;
      $scope.pageList = [];
      $scope.selPage = 1;
      //设置表格数据源(分页)
      $scope.setData= function () {
        $scope.names = $scope.data.slice(($scope.pageSize * ($scope.selPage - 1)), ($scope.selPage * $scope.pageSize));//通过当前页数筛选出表格当前显示数据
      },
      $scope.names = $scope.data.slice(0, $scope.pageSize);
      //分页要repeat的数组
      for (var i = 0; i < $scope.newPages; i++) {
        $scope.pageList.push(i + 1);
      }
      //打印当前选中页索引
      $scope.selectPage = function (page) {
        //不能小于1大于最大
        
        if (page < 1 || page > $scope.pages) return;
        
        //最多显示分页数5
        if (page > 2) {
          //因为只显示5个页数，大于2页开始分页转换
          var newpageList = [];
          for (var i = (page - 3) ; i < ((page + 2) > $scope.pages ? $scope.pages : (page + 2)) ; i++) {
       
            newpageList.push(i + 1);
          }
          $scope.pageList = newpageList;
        }else if (page ==1||page==2) {
          //因为只显示5个页数，大于2页开始分页转换
          var newpageList = [];
          for (var i = 1 ; i < $scope.pages+1; i++) {
            newpageList.push(i);
          }
          $scope.pageList = newpageList;
        }
        $scope.selPage = page;
        $scope.setData();
        $scope.isActivePage(page);
        console.log("选择的页：" + page);
      };
      //设置当前选中页样式
      $scope.isActivePage = function (page) {
        return $scope.selPage == page;
      };
      //上一页
      $scope.Previous = function () {
        $scope.selectPage($scope.selPage - 1);
      }
      //下一页
      $scope.Next = function () {
        $scope.selectPage($scope.selPage + 1);
        var a;
      };	
        $scope.Sy = function () {
        $scope.selectPage(1);
      };
         $scope.Wy = function () {
        $scope.selectPage( $scope.pages);
     				 };	
				});
			};
			/** 发送邮件JS */
			$scope.fsyj = function() {
				$scope.fsyjdiv = false;
				$scope.jsyjdiv = true;
				$scope.yfyjdiv = true;
                $scope.ckdiv=true;
			$scope.tj = function() {
				if($scope.zhuti!="" && $scope.zhengwen!=""){
					$scope.params = {
					ZT : $scope.zhuti,
					ZW : $scope.zhengwen
				};
				$http({
					url : getPath() + "/wsyyt/grXinXController/test",
					contentType : "text/html;charset=utf-8",
					method : 'post',
					params : $scope.params,
				}).then(function(res) {
					$scope.code = res.data.code;
					if ($scope.code == 0) {
						layer.msg('提示：提交成功',{icon: 5});
						$scope.zhuti = "";
						$scope.zhengwen = "";
					} else {
						layer.msg('提示：'+res.data.CW,{icon: 5});
					}

				});
				}else{
					layer.msg('提示：提交失败',{icon: 5});
				}
				
			  };
			  $scope.cz=function(){
			     $scope.cz=function(){
			    $scope.zhuti = "";
				$scope.zhengwen = "";
			  };
			  };
			};
			/**已发邮件  */
				$scope.yfyj = function() {
				$scope.fsyjdiv = true;
				$scope.jsyjdiv = true;
				$scope.yfyjdiv = false;
				$scope.ckdiv=true;
				$scope.params = {
					id : $scope.id,
				};
				$http({
					url : getPath() + "/wsyyt/grXinXController/test2",
					contentType : "text/html;charset=utf-8",
					method : 'post',
					params : $scope.params,
				}).then(function(res) {
				      $scope.data = res.data.data;
				      if(res.data.code==1){
				   	 	layer.msg('提示：'+res.data.CW,{icon: 5});
				   	 }
                 $scope.pageSize = 8;//设置显示行数
      $scope.pages = Math.ceil($scope.data.length / $scope.pageSize); //分页数
      $scope.newPages = $scope.pages > 5 ? 5 : $scope.pages;
      $scope.pageList = [];
      $scope.selPage = 1;
      //设置表格数据源(分页)
      $scope.setData= function () {
        $scope.names = $scope.data.slice(($scope.pageSize * ($scope.selPage - 1)), ($scope.selPage * $scope.pageSize));//通过当前页数筛选出表格当前显示数据
      },
      $scope.names = $scope.data.slice(0, $scope.pageSize);
      //分页要repeat的数组
      for (var i = 0; i < $scope.newPages; i++) {
        $scope.pageList.push(i + 1);
      }
      //打印当前选中页索引
      $scope.selectPage = function (page) {
        //不能小于1大于最大
        
        if (page < 1 || page > $scope.pages) return;
        
        //最多显示分页数5
        if (page > 2) {
          //因为只显示5个页数，大于2页开始分页转换
          var newpageList = [];
          for (var i = (page - 3) ; i < ((page + 2) > $scope.pages ? $scope.pages : (page + 2)) ; i++) {
       
            newpageList.push(i + 1);
          }
          $scope.pageList = newpageList;
        }else if (page ==1||page==2) {
          //因为只显示5个页数，大于2页开始分页转换
          var newpageList = [];
          for (var i = 1 ; i < $scope.pages+1; i++) {
            newpageList.push(i);
          }
          $scope.pageList = newpageList;
        }
        $scope.selPage = page;
        $scope.setData();
        $scope.isActivePage(page);
        console.log("选择的页：" + page);
      };
      //设置当前选中页样式
      $scope.isActivePage = function (page) {
        return $scope.selPage == page;
      };
      //上一页
      $scope.Previous = function () {
        $scope.selectPage($scope.selPage - 1);
      }
      //下一页
      $scope.Next = function () {
        $scope.selectPage($scope.selPage + 1);
        var a;
      };	
        $scope.Sy = function () {
        $scope.selectPage(1);
      };
         $scope.Wy = function () {
        $scope.selectPage( $scope.pages);
     		       };	
			   });
			};
		  $scope.ck=function(index){
				  $scope.fsyjdiv = true;
				  $scope.jsyjdiv = true;
				  $scope.yfyjdiv = true;
				  $scope.ckdiv=false;
				   var data =$scope.data;
				  $scope.params = {	id : data[index].ID,};
				  $http({
					url : getPath() + "/wsyyt/grXinXController/test2",
					contentType : "text/html;charset=utf-8",
					params : $scope.params,
					method : 'post',
				}).then(function(res) {
				      $scope.ckzhuti2=data[index].ZT;
				      $scope.ckzhengwen=res.data.data[0].ZW;
				  }); 
		     };  
		});
	</script>
</body>
</html>